#include "go_conf.h"
#include "utils.h"
#include "goboard.h"
#include "nbrcounter.h"
#include "zobrist.h"
PmRandom zobrist_pm;
extern  const char col_tab[];
const char col_tab[] = "ABCDEFGHJKLMNOPQRSTUVWXYZ";
/*
const uint board_size  = 9;
const uint board_area          = board_size * board_size;
const uint max_empty_v_cnt     = board_area;
const uint max_game_length     = board_area * 4;
const uint max_playout_length  = board_area * 2;
*/
const uint NbrCounter::cnt_map[player::cnt][NbrCounter::cnt] = { 
{// empty
	4,3,3,3,3,2,2,2,3,2,2,2,3,2,2,2,
	3,2,2,2,2,1,1,1,2,1,1,1,2,1,1,1,
	3,2,2,2,2,1,1,1,2,1,1,1,2,1,1,1,
	3,2,2,2,2,1,1,1,2,1,1,1,2,1,1,1,
	3,2,2,2,2,1,1,1,2,1,1,1,2,1,1,1,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	3,2,2,2,2,1,1,1,2,1,1,1,2,1,1,1,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	3,2,2,2,2,1,1,1,2,1,1,1,2,1,1,1,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
	2,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,
},
{// black
	0,1,0,1,1,2,1,2,0,1,0,1,1,2,1,2,
	1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,
	0,1,0,1,1,2,1,2,0,1,0,1,1,2,1,2,
	1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,
	1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,
	2,3,2,3,3,4,3,4,2,3,2,3,3,4,3,4,
	1,2,1,2,2,3,2,3,1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